<!-- saved from url=(0014)about:internet -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Toast.as</title>
<link rel="stylesheet" type="text/css" href="../../../SourceStyles.css"/>
</head>

<body><pre><span class="ActionScriptComment">////////////////////////////////////////////////////////////////////////////////
</span><span class="ActionScriptComment">//
</span><span class="ActionScriptComment">//  Licensed to the Apache Software Foundation (ASF) under one or more
</span><span class="ActionScriptComment">//  contributor license agreements.  See the NOTICE file distributed with
</span><span class="ActionScriptComment">//  this work for additional information regarding copyright ownership.
</span><span class="ActionScriptComment">//  The ASF licenses this file to You under the Apache License, Version 2.0
</span><span class="ActionScriptComment">//  (the "License"); you may not use this file except in compliance with
</span><span class="ActionScriptComment">//  the License.  You may obtain a copy of the License at
</span><span class="ActionScriptComment">//
</span><span class="ActionScriptComment">//      http://www.apache.org/licenses/LICENSE-2.0
</span><span class="ActionScriptComment">//
</span><span class="ActionScriptComment">//  Unless required by applicable law or agreed to in writing, software
</span><span class="ActionScriptComment">//  distributed under the License is distributed on an "AS IS" BASIS,
</span><span class="ActionScriptComment">//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
</span><span class="ActionScriptComment">//  See the License for the specific language governing permissions and
</span><span class="ActionScriptComment">//  limitations under the License.
</span><span class="ActionScriptComment">//
</span><span class="ActionScriptComment">////////////////////////////////////////////////////////////////////////////////
</span>
<span class="ActionScriptpackage">package</span> <span class="ActionScriptDefault_Text">spark</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">components</span>
<span class="ActionScriptBracket/Brace">{</span>
    <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">flash</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">display</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">DisplayObject</span>;
    <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">flash</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">events</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">Event</span>;
    <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">flash</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">events</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">TimerEvent</span>;
    <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">flash</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">utils</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">Timer</span>;
    <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">flash</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">utils</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">setTimeout</span>;
    
    <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">mx</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">core</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">FlexGlobals</span>;
    <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">mx</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">core</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">IFlexDisplayObject</span>;
    <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">mx</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">managers</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">PopUpManager</span>;
    
    <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">spark</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">components</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">SkinnablePopUpContainer</span>;
    
    <span class="ActionScriptASDoc">/**
     *  The alpha of border stroke.
     *
     *  @default 0.65
     *
     *  @langversion 3.0
     *  @playerversion AIR 3
     *  @productversion Flex 4.6
     */</span>
    <span class="ActionScriptBracket/Brace">[</span><span class="ActionScriptMetadata">Style</span><span class="ActionScriptBracket/Brace">(</span> <span class="ActionScriptString">"strokeAlpha"</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">type</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptString">"Number"</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">inherit</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptString">"no"</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">minValue</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptString">"0.0"</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">maxValue</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptString">"1.0"</span><span class="ActionScriptBracket/Brace">)</span><span class="ActionScriptBracket/Brace">]</span>
    
    <span class="ActionScriptASDoc">/**
     *  The color of border stroke.
     *
     *  @default 0xFFFFFF
     *
     *  @langversion 3.0
     *  @playerversion AIR 3
     *  @productversion Flex 4.6
     */</span>
    <span class="ActionScriptBracket/Brace">[</span><span class="ActionScriptMetadata">Style</span><span class="ActionScriptBracket/Brace">(</span> <span class="ActionScriptString">"strokeColor"</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">type</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptString">"uint"</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">format</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptString">"Color"</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">inherit</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptString">"no"</span><span class="ActionScriptBracket/Brace">)</span><span class="ActionScriptBracket/Brace">]</span>
    
    <span class="ActionScriptASDoc">/**
     *  The radius of the corners of the notification box.
     *
     *  @default 0
     *
     *  @langversion 3.0
     *  @playerversion AIR 3
     *  @productversion Flex 4.6
     */</span>
    <span class="ActionScriptBracket/Brace">[</span><span class="ActionScriptMetadata">Style</span><span class="ActionScriptBracket/Brace">(</span> <span class="ActionScriptString">"cornerRadius"</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">type</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptString">"Number"</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">inherit</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptString">"no"</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">minValue</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptString">"0"</span><span class="ActionScriptBracket/Brace">)</span><span class="ActionScriptBracket/Brace">]</span>
    
    <span class="ActionScriptASDoc">/**
     *  The Spark Toast control defines lightweight feedback mechanism in a
     *  small popup that automatically disappears after a set period of time.
     *     Toasts do not have any interactive controls and only display
     *     information to the user.
     *
     *     A Toast consists of a box and a label.
     *
     *  @langversion 3.0
     *  @playerversion AIR 3
     *  @productversion Flex 4.6
     *
     *  @see spark.skins.mobile.ToastSkin
     */</span>
    <span class="ActionScriptReserved">public</span> <span class="ActionScriptclass">class</span> <span class="ActionScriptDefault_Text">Toast</span> <span class="ActionScriptReserved">extends</span> <span class="ActionScriptDefault_Text">SkinnablePopUpContainer</span>
    <span class="ActionScriptBracket/Brace">{</span>
        <span class="ActionScriptReserved">public</span> <span class="ActionScriptReserved">static</span> <span class="ActionScriptReserved">const</span> <span class="ActionScriptDefault_Text">LONG_DELAY</span>:<span class="ActionScriptDefault_Text">int</span> <span class="ActionScriptOperator">=</span> 3500; <span class="ActionScriptComment">// 3.5 seconds
</span>        
        <span class="ActionScriptReserved">public</span> <span class="ActionScriptReserved">static</span> <span class="ActionScriptReserved">const</span> <span class="ActionScriptDefault_Text">SHORT_DELAY</span>:<span class="ActionScriptDefault_Text">int</span> <span class="ActionScriptOperator">=</span> 2000; <span class="ActionScriptComment">// 2 seconds
</span>        
        <span class="ActionScriptComment">//----------------------------------------------------------------------------------------------
</span>        <span class="ActionScriptComment">//
</span>        <span class="ActionScriptComment">//  Variables
</span>        <span class="ActionScriptComment">//
</span>        <span class="ActionScriptComment">//----------------------------------------------------------------------------------------------
</span>        
        <span class="ActionScriptASDoc">/**
         * Flag indicating if the toast is currently showing
         */</span>
        <span class="ActionScriptReserved">private</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">showing</span>:<span class="ActionScriptDefault_Text">Boolean</span>;
        
        <span class="ActionScriptASDoc">/**
         * Internal timer for determining when toast should disappear
         */</span>
        <span class="ActionScriptReserved">private</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">popupTimer</span>:<span class="ActionScriptDefault_Text">Timer</span>;
        
        <span class="ActionScriptComment">//----------------------------------------------------------------------------------------------
</span>        <span class="ActionScriptComment">//
</span>        <span class="ActionScriptComment">//  Constructor
</span>        <span class="ActionScriptComment">//
</span>        <span class="ActionScriptComment">//----------------------------------------------------------------------------------------------
</span>        
        <span class="ActionScriptASDoc">/**
         *  Constructor.
         *
         *  @langversion 3.0
         *  @playerversion AIR 3
         *  @productversion Flex 4.6
         */</span>
        <span class="ActionScriptReserved">public</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">Toast</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">label</span>:<span class="ActionScriptDefault_Text">String</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">duration</span>:<span class="ActionScriptDefault_Text">int</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">SHORT_DELAY</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">notificationParent</span>:<span class="ActionScriptDefault_Text">DisplayObject</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">null</span><span class="ActionScriptBracket/Brace">)</span>
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptReserved">super</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>;
            
            <span class="ActionScriptDefault_Text">_label</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">label</span>;
            <span class="ActionScriptDefault_Text">_duration</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">duration</span>;
            <span class="ActionScriptDefault_Text">_notificationParent</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">notificationParent</span> <span class="ActionScriptOperator">?</span> <span class="ActionScriptDefault_Text">notificationParent</span> : <span class="ActionScriptDefault_Text">FlexGlobals</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">topLevelApplication</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">root</span>;
            
            <span class="ActionScriptDefault_Text">init</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>;
        <span class="ActionScriptBracket/Brace">}</span>
        
        <span class="ActionScriptComment">//----------------------------------------------------------------------------------------------
</span>        <span class="ActionScriptComment">//
</span>        <span class="ActionScriptComment">//  Properties
</span>        <span class="ActionScriptComment">//
</span>        <span class="ActionScriptComment">//----------------------------------------------------------------------------------------------
</span>        
        
        <span class="ActionScriptComment">//----------------------------------
</span>        <span class="ActionScriptComment">//  label
</span>        <span class="ActionScriptComment">//----------------------------------
</span>        
        <span class="ActionScriptReserved">private</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">_label</span>:<span class="ActionScriptDefault_Text">String</span>;
        
        <span class="ActionScriptBracket/Brace">[</span><span class="ActionScriptMetadata">Bindable</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptString">"change"</span><span class="ActionScriptBracket/Brace">)</span><span class="ActionScriptBracket/Brace">]</span>
        <span class="ActionScriptASDoc">/**
         *
         * @return
         *  String
         */</span>
        <span class="ActionScriptReserved">public</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptReserved">get</span> <span class="ActionScriptDefault_Text">label</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>:<span class="ActionScriptDefault_Text">String</span>
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptReserved">return</span> <span class="ActionScriptDefault_Text">_label</span>;
        <span class="ActionScriptBracket/Brace">}</span>
        
        <span class="ActionScriptReserved">public</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptReserved">set</span> <span class="ActionScriptDefault_Text">label</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">value</span>:<span class="ActionScriptDefault_Text">String</span><span class="ActionScriptBracket/Brace">)</span>:<span class="ActionScriptReserved">void</span>
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptReserved">if</span> <span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">_label</span> <span class="ActionScriptOperator">==</span> <span class="ActionScriptDefault_Text">value</span><span class="ActionScriptBracket/Brace">)</span>
                <span class="ActionScriptReserved">return</span>;
            
            <span class="ActionScriptDefault_Text">_label</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">value</span>;
            
            <span class="ActionScriptReserved">if</span> <span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">hasEventListener</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">Event</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">CHANGE</span><span class="ActionScriptBracket/Brace">)</span><span class="ActionScriptBracket/Brace">)</span>
                <span class="ActionScriptDefault_Text">dispatchEvent</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">Event</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">Event</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">CHANGE</span><span class="ActionScriptBracket/Brace">)</span><span class="ActionScriptBracket/Brace">)</span>;
        <span class="ActionScriptBracket/Brace">}</span>
        
        <span class="ActionScriptComment">//----------------------------------
</span>        <span class="ActionScriptComment">//  duration
</span>        <span class="ActionScriptComment">//----------------------------------
</span>        
        <span class="ActionScriptReserved">private</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">_duration</span>:<span class="ActionScriptDefault_Text">int</span>;
        
        <span class="ActionScriptASDoc">/**
         * The duration in milliseconds that the notification should be visible
         * to the user before disappearing.
         *
         * @return
         *  The duration in milliseconds.
         */</span>
        <span class="ActionScriptReserved">public</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptReserved">get</span> <span class="ActionScriptDefault_Text">duration</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>:<span class="ActionScriptDefault_Text">int</span>
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptReserved">return</span> <span class="ActionScriptDefault_Text">_duration</span>;
        <span class="ActionScriptBracket/Brace">}</span>
        
        <span class="ActionScriptASDoc">/**
         * @private
         */</span>
        <span class="ActionScriptReserved">public</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptReserved">set</span> <span class="ActionScriptDefault_Text">duration</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">value</span>:<span class="ActionScriptDefault_Text">int</span><span class="ActionScriptBracket/Brace">)</span>:<span class="ActionScriptReserved">void</span>
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptReserved">if</span> <span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">_duration</span> <span class="ActionScriptOperator">==</span> <span class="ActionScriptDefault_Text">value</span><span class="ActionScriptBracket/Brace">)</span>
                <span class="ActionScriptReserved">return</span>;
            
            <span class="ActionScriptDefault_Text">_duration</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">value</span>;
        <span class="ActionScriptBracket/Brace">}</span>
        
        <span class="ActionScriptComment">//----------------------------------
</span>        <span class="ActionScriptComment">//  notificationParent
</span>        <span class="ActionScriptComment">//----------------------------------
</span>        
        <span class="ActionScriptReserved">private</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">_notificationParent</span>:<span class="ActionScriptDefault_Text">DisplayObject</span>;
        
        <span class="ActionScriptASDoc">/**
         * The object that toasts should be displayed in. This allows toasts to
         * be confined to areas where they have meaning or context.
         *
         * @return
         *     A DisplayObject.
         */</span>
        <span class="ActionScriptReserved">public</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptReserved">get</span> <span class="ActionScriptDefault_Text">notificationParent</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>:<span class="ActionScriptDefault_Text">DisplayObject</span>
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptReserved">return</span> <span class="ActionScriptDefault_Text">_notificationParent</span>;
        <span class="ActionScriptBracket/Brace">}</span>
        
        <span class="ActionScriptComment">//----------------------------------------------------------------------------------------------
</span>        <span class="ActionScriptComment">//
</span>        <span class="ActionScriptComment">//  Methods
</span>        <span class="ActionScriptComment">//
</span>        <span class="ActionScriptComment">//----------------------------------------------------------------------------------------------
</span>        
        <span class="ActionScriptReserved">private</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">init</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>:<span class="ActionScriptReserved">void</span>
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptComment">// create a timer to control visibility
</span>            <span class="ActionScriptDefault_Text">popupTimer</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">Timer</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">_duration</span><span class="ActionScriptOperator">,</span> 1<span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptDefault_Text">popupTimer</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">addEventListener</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">TimerEvent</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">TIMER</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">popupTimer_handler</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptReserved">false</span><span class="ActionScriptOperator">,</span> 0<span class="ActionScriptOperator">,</span> <span class="ActionScriptReserved">true</span><span class="ActionScriptBracket/Brace">)</span>;
        <span class="ActionScriptBracket/Brace">}</span>
        
        <span class="ActionScriptASDoc">/**
         * Convenience method for creating a toast.
         * @param label
         *     The label to display to the user
         * @param duration
         *     The duration in milliseconds to display the notification. The default
         *     is SHORT_DELAY (2 seconds)
         * @param parent
         *     The parent component to notify in. Default is the application.
         * @return
         *     A created toast.
         */</span>
        <span class="ActionScriptReserved">public</span> <span class="ActionScriptReserved">static</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">makeInstance</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">label</span>:<span class="ActionScriptDefault_Text">String</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">duration</span>:<span class="ActionScriptDefault_Text">int</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">SHORT_DELAY</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">parent</span>:<span class="ActionScriptDefault_Text">DisplayObject</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">null</span><span class="ActionScriptBracket/Brace">)</span>:<span class="ActionScriptDefault_Text">Toast</span>
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptReserved">return</span> <span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">Toast</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">label</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">duration</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">parent</span><span class="ActionScriptBracket/Brace">)</span>;
        <span class="ActionScriptBracket/Brace">}</span>
        
        <span class="ActionScriptASDoc">/**
         * Show the toast to the user
         */</span>
        <span class="ActionScriptReserved">public</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">show</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>:<span class="ActionScriptReserved">void</span>
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptReserved">if</span> <span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">popupTimer</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">running</span><span class="ActionScriptBracket/Brace">)</span>
                <span class="ActionScriptDefault_Text">popupTimer</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">stop</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>;
            
            <span class="ActionScriptComment">// reset and restart our timer
</span>            <span class="ActionScriptDefault_Text">popupTimer</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">reset</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptDefault_Text">popupTimer</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">start</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>;
            
            <span class="ActionScriptComment">// If we're not already showing then show it; otherwise, we're really
</span>            <span class="ActionScriptComment">// just extending the amount of time that we are shown
</span>            <span class="ActionScriptReserved">if</span> <span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptOperator">!</span><span class="ActionScriptDefault_Text">showing</span><span class="ActionScriptBracket/Brace">)</span>
            <span class="ActionScriptBracket/Brace">{</span>
                <span class="ActionScriptDefault_Text">PopUpManager</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">addPopUp</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptReserved">this</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">_notificationParent</span><span class="ActionScriptBracket/Brace">)</span>;
                <span class="ActionScriptDefault_Text">showing</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">true</span>;
            <span class="ActionScriptBracket/Brace">}</span>
        <span class="ActionScriptBracket/Brace">}</span>
        
        <span class="ActionScriptASDoc">/**
         * Hide the toast from the user prior to it hiding itself
         */</span>
        <span class="ActionScriptReserved">public</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">hide</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>:<span class="ActionScriptReserved">void</span>
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptComment">// stop our timer
</span>            <span class="ActionScriptReserved">if</span> <span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">popupTimer</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">running</span><span class="ActionScriptBracket/Brace">)</span>
                <span class="ActionScriptDefault_Text">popupTimer</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">stop</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>;
            
            <span class="ActionScriptComment">// remove our notification
</span>            <span class="ActionScriptReserved">if</span> <span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">showing</span><span class="ActionScriptBracket/Brace">)</span>
            <span class="ActionScriptBracket/Brace">{</span>
                <span class="ActionScriptDefault_Text">PopUpManager</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">removePopUp</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptReserved">this</span><span class="ActionScriptBracket/Brace">)</span>;
                <span class="ActionScriptDefault_Text">showing</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">false</span>;
            <span class="ActionScriptBracket/Brace">}</span>
        <span class="ActionScriptBracket/Brace">}</span>
        
        <span class="ActionScriptASDoc">/**
         * Convenience method for tearing down the toast to a point where it
         * can be garbage collected.
         */</span>
        <span class="ActionScriptReserved">public</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">dispose</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>:<span class="ActionScriptReserved">void</span>
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptReserved">if</span> <span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">showing</span><span class="ActionScriptBracket/Brace">)</span>
            <span class="ActionScriptBracket/Brace">{</span>
                <span class="ActionScriptDefault_Text">PopUpManager</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">removePopUp</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptReserved">this</span><span class="ActionScriptBracket/Brace">)</span>;
                <span class="ActionScriptDefault_Text">showing</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">false</span>;
            <span class="ActionScriptBracket/Brace">}</span>
            
            <span class="ActionScriptReserved">if</span> <span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">popupTimer</span><span class="ActionScriptBracket/Brace">)</span>
            <span class="ActionScriptBracket/Brace">{</span>
                <span class="ActionScriptReserved">if</span> <span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">popupTimer</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">hasEventListener</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">TimerEvent</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">TIMER</span><span class="ActionScriptBracket/Brace">)</span><span class="ActionScriptBracket/Brace">)</span>
                    <span class="ActionScriptDefault_Text">popupTimer</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">removeEventListener</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">TimerEvent</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">TIMER</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">popupTimer_handler</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptReserved">false</span><span class="ActionScriptBracket/Brace">)</span>;
                
                <span class="ActionScriptDefault_Text">popupTimer</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">stop</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>;
                <span class="ActionScriptDefault_Text">popupTimer</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">null</span>;
            <span class="ActionScriptBracket/Brace">}</span>
        <span class="ActionScriptBracket/Brace">}</span>
        
        <span class="ActionScriptComment">//----------------------------------------------------------------------------------------------
</span>        <span class="ActionScriptComment">//
</span>        <span class="ActionScriptComment">//  Event Handlers
</span>        <span class="ActionScriptComment">//
</span>        <span class="ActionScriptComment">//----------------------------------------------------------------------------------------------
</span>        
        <span class="ActionScriptReserved">protected</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">popupTimer_handler</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">event</span>:<span class="ActionScriptDefault_Text">TimerEvent</span><span class="ActionScriptBracket/Brace">)</span>:<span class="ActionScriptReserved">void</span>
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptDefault_Text">hide</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>;
        <span class="ActionScriptBracket/Brace">}</span>
        
    <span class="ActionScriptBracket/Brace">}</span>
<span class="ActionScriptBracket/Brace">}</span></pre></body>
</html>
